
public class MementoExample {

	public static void main(String[] args) {
		CareTaker careTaker=new CareTaker();
		Originator originator=new Originator();
		originator.set("State1");
		originator.set("State2");
		careTaker.addMemento(originator.saveToMemento());
		originator.set("State 3"); 
		careTaker.addMemento(originator.saveToMemento()); 
		originator.set("State 4");
		System.out.println("Restoring back to previous state ...");
		originator.restoreFromMemento(careTaker.getMemento(0)); 	  
	}
}
